Re: novice question about NOTICE:... - Mailing list pgsql-novice

From Lloyd Vancil
Subject Re: novice question about NOTICE:...
Date
Msg-id a05101035b8d12999c9e3@[17.207.13.64]
Whole thread Raw
In response to novice question about NOTICE:...  (Lloyd Vancil <lev@apple.com>)
List pgsql-novice
Thanks Doug.
    But then it came up with
ERROR:  Column reference "oid" is ambiguous.
and eventually
ERROR:  Column reference "lang" is ambiguous
    because -every- table has an OID and in this case both tables have
a column 'lang'


so, correctly it is
select cgidat.oid, cgidat.lang from cgidat, tierdat where
cgidat.state = 'testing' and
cgidat.lang = tiredat.lang and
tierdat.tier = '0' order by lang;
And if you dont select lang then the order by has to be qualified too.


select cgidat.oid from cgidat, tierdat where
cgidat.state = 'testing' and
cgidat.lang = tiredat.lang and
tierdat.tier = '0' order by cgidat.lang;

At 12:55 PM -0800 4/3/02, Doug Silver wrote:
>
>That was mighty nice of Postgres to fix your query -- I didn't know it
>would do that.  You're doing a join from two tables, cgidat and tierdat,
>so you must include them in your FROM clause:
>
>select oid, lang from cgidat, tierdat where
>cgidat.state = 'testing' and
>cgidat.lang = tiredat.lang and
>tierdat.tier = '0' order by lang;
>
>or using aliases (a must when you start joining several tables):
>
>select c.oid,c.lang from cgidat c, tierdat t where
>c.state='testing' and
>c.lang = t.lang and
>t.tier ='0' order by c.lang

--
searchmaster@apple.com
                 lev@apple.com

pgsql-novice by date:

Previous
From: Doug Silver
Date:
Subject: Re: novice question about NOTICE:...
Next
From: "Morrison, Trevor (Trevor)"
Date:
Subject: FW: readline and psql